#include "ConfigFileTest.h"

using namespace std;

ConfigFileTest::ConfigFileTest( void ) {}

int ConfigFileTest::testLoad( void )
{
    cout << "Testing ConfigFile" << endl;
    int nbErrors = 0;
    ConfigFile source;

    if( ! source.load( "./existing.cfg" ) )
    {
        cout << "\t[ERROR] source.load( \"./existing.cfg\" )" << endl;
        nbErrors++;
    }

    int width = source[ "video" ][ "width" ].getInt();

    if( width != 1024 )
    {
        cout << "\t[ERROR] source[ \"video\" ][ \"width\" ].getInt() - waited=1024 != " << width << endl;
        nbErrors++;
    }

    float height = source[ "video" ][ "height" ].getFloat();

    if( height != 7681.0f )
    {
        cout << "\t[ERROR] source[ \"video\" ][ \"width\" ].getInt() - waited=768 != " << height << endl;
        nbErrors++;
    }
    if( nbErrors == 0 )
    {
        cout << "ConfigFile test : OK" << endl;
    }
    else
    {
        cout << "ConfigFile test : " << nbErrors << " errors" << endl;
    }
    return nbErrors;
}
